package main

import (
	"fmt"
	"strings"
)

// strings 的函数汇总
func main() {

	// buildin

	fmt.Println(len("123"))
	fmt.Println(len("123中国"))

	//中文长度的处理
	str := []rune("123中国")
	fmt.Println(len(str))

	str2 := "hello北京"

	runeStr2 := []rune(str2)

	for i := 0; i < len(runeStr2); i++ {
		fmt.Printf("字符=== %c \n", runeStr2[i])
		fmt.Printf("字符2=== %v \n", string(runeStr2[i]))
	}

	fmt.Println("strings.Count", strings.Count("123123", "1"))

	fmt.Println("strings.Contains", strings.Contains("abc", "a"))
	fmt.Println("strings.Contains", strings.Contains("abc", "w"))
	fmt.Println("strings.EqualFold", strings.EqualFold("abc", "A"))

	fmt.Println("strings.Index", strings.Index("123123_hello", "_"))
	fmt.Println("strings.Index", strings.Index("123123_hello", "*"))
	fmt.Println("strings.Index", strings.Index("123123_hello", "3"))

	fmt.Println("strings.Index", strings.Index("123123_hello", "1"))

	fmt.Println("strings.LastIndex", strings.LastIndex("123123_hello", "1"))
}
